package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsBpCategory;
import com.bestow.basic.service.IHlsBpCategoryService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 商业伙伴类别Controller
 * 
 * @author liliu
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/basic/bpCategory")
public class HlsBpCategoryController extends BaseController
{
    @Autowired
    private IHlsBpCategoryService hlsBpCategoryService;

    /**
     * 查询商业伙伴类别列表
     */
    @PreAuthorize("@ss.hasPermi('basic:bpCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsBpCategory hlsBpCategory)
    {
        startPage();
        List<HlsBpCategory> list = hlsBpCategoryService.selectHlsBpCategoryList(hlsBpCategory);
        return getDataTable(list);
    }

    /**
     * 导出商业伙伴类别列表
     */
    @PreAuthorize("@ss.hasPermi('basic:bpCategory:export')")
    @Log(title = "商业伙伴类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsBpCategory hlsBpCategory)
    {
        List<HlsBpCategory> list = hlsBpCategoryService.selectHlsBpCategoryList(hlsBpCategory);
        ExcelUtil<HlsBpCategory> util = new ExcelUtil<HlsBpCategory>(HlsBpCategory.class);
        util.exportExcel(response, list, "商业伙伴类别数据");
    }

    /**
     * 获取商业伙伴类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:bpCategory:query')")
    @GetMapping(value = "/{bpCategory}")
    public AjaxResult getInfo(@PathVariable("bpCategory") String bpCategory)
    {
        return AjaxResult.success(hlsBpCategoryService.selectHlsBpCategoryByBpCategory(bpCategory));
    }

    /**
     * 新增商业伙伴类别
     */
    @PreAuthorize("@ss.hasPermi('basic:bpCategory:add')")
    @Log(title = "商业伙伴类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsBpCategory hlsBpCategory)
    {
        return toAjax(hlsBpCategoryService.insertHlsBpCategory(hlsBpCategory));
    }

    /**
     * 修改商业伙伴类别
     */
    @PreAuthorize("@ss.hasPermi('basic:bpCategory:edit')")
    @Log(title = "商业伙伴类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsBpCategory hlsBpCategory)
    {
        return toAjax(hlsBpCategoryService.updateHlsBpCategory(hlsBpCategory));
    }

    /**
     * 删除商业伙伴类别
     */
    @PreAuthorize("@ss.hasPermi('basic:bpCategory:remove')")
    @Log(title = "商业伙伴类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bpCategorys}")
    public AjaxResult remove(@PathVariable String[] bpCategorys)
    {
        return toAjax(hlsBpCategoryService.deleteHlsBpCategoryByBpCategorys(bpCategorys));
    }
}
